package com.example.shop.service.impl;

import com.example.shop.entity.Productstype;
import com.example.shop.dao.ProductstypeMapper;
import com.example.shop.service.ProductstypeService;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;

/**
 * (Productstype)表服务实现类
 *
 * @author makejava
 * @since 2025-03-26 09:28:06
 */
@Service("productstypeService")
public class ProductstypeServiceImpl implements ProductstypeService {
    @Resource
    private ProductstypeMapper productstypeMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param productstypeid 主键
     * @return 实例对象
     */
    @Override
    public Productstype queryById(Integer productstypeid) {
        return this.productstypeMapper.queryById(productstypeid);
    }


    /**
     * 新增数据
     *
     * @param productstype 实例对象
     * @return 实例对象
     */
    @Override
    public Productstype insert(Productstype productstype) {
        this.productstypeMapper.insert(productstype);
        return productstype;
    }

    /**
     * 修改数据
     *
     * @param productstype 实例对象
     * @return 实例对象
     */
    @Override
    public Productstype update(Productstype productstype) {
        this.productstypeMapper.update(productstype);
        return this.queryById(productstype.getProductstypeid());
    }

    /**
     * 通过主键删除数据
     *
     * @param productstypeid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer productstypeid) {
        return this.productstypeMapper.deleteById(productstypeid) > 0;
    }
}
